package com.android.nextBus.XML;

import java.util.ArrayList;
import java.util.List;

import com.android.nextBus.Data.BusStopData;

public class ObjectParsers {

	// ad hoc REGEX solution to parsing XML response
	public static List<BusStopData> parseGameResponse(String response) {
		List<BusStopData> data = new ArrayList<BusStopData>();
		String insideContents = RegexParser.regex("<stops>(.*)</stops>",
				response);
		String[] contents = insideContents.split("<stop>");
		for (String content : contents) {
			if (content.equals("")) {
				continue;
			}
			String name = RegexParser.regex(">([^>]*)</name>", content);
			String id = RegexParser.regex(">([^>]*)</stopId>", content);

			BusStopData d = new BusStopData(id, name);
			data.add(d);
		}
		return data;
	}
}
